<?php
class IndexAction extends CommonAction {

	public function _initialize()
	{
		parent::_initialize();
	}

    public function index()
    {
    	$article=D('Article');
    	$indexArticle=$article->getArticleListByMap('',12,0,'id DESC');
    	$this->assign('indexArticle',$indexArticle);
        $seo=seo('','',1);
        $this->assign('seo',$seo);
    	$this->display();
    }

    public function test()
    {
       if ($_SERVER['REQUEST_METHOD'] == 'POST') {

    $ret=array('strings'=>$_POST,'error'=>'0');

    $fs=array();

    foreach ( $_FILES as $name=>$file ) {

        $fn=$file['name'];

        $fs[$name]=array('name'=>$fn,'type'=>$file['type'],'size'=>$file['size']);
    }

    $ret['files']=$fs;

    echo json_encode($ret);
}else{
    echo "{'error':'Unsupport GET request!'}";
}

    }

    public function uploadtest()
    {

        import('@.ORG.UploadFile');
        $upload = new UploadFile();// 实例化上传类
        $upload->maxSize  = 3145728 ;// 设置附件上传大小
        $upload->allowExts  = array('jpg', 'gif', 'png', 'jpeg');// 设置附件上传类型
        $upload->savePath =  './Public/Uploads/';// 设置附件上传目录
        if(!$upload->upload()) {// 上传错误提示错误信息
            echo $upload->getErrorMsg();
        }else{// 上传成功 获取上传文件信息
                $info =  $upload->getUploadFileInfo();
            echo json_encode($info);
        }

    }
}